<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>pivot chart</title>
<link href="UniversalStyleSheet.css" rel="stylesheet" type="text/css" />
<style type="text/css">
select { background-color:#FFFF99}

</style>

<script type="text/vbscript">
function 	UpdateExample()
	set m=document.getelementById("Measure")
	set mo=document.getelementById("MeasureObj")
	set e=document.getelementById("EachObj")
	set g=document.getelementById("GroupedByObj")
	
	if m.selectedindex<>-1 and mo.selectedindex<>-1 then
		cfill=m.options(m.selectedindex).value & " of " & mo.options(mo.selectedindex).value
	end if
	
	if e.selectedindex<>-1 then
		efill=e.value
	end if
	
	if g.selectedindex<>-1 then
		gfill=g.value
	end if
	
	if efill<>"" then
		for x=1 to 3
			document.getElementById("e" & x).innertext=efill & " " & x
		next
	end if
	
	if gfill<>"" then
		for x=1 to 3
			document.getElementById("g" & x).innertext=gfill & " " & x
		next
	end if
	
	if cfill<>"" then
		for x=1 to 3
			for y=1 to 3
				document.getElementById("c" & x & "-" & y).innertext=cfill & " " & x & "-" & y
			next
		next
	end if
	
end function
</script>
</head>

<body>
<%
if request.form("table")<>"" then
	dim rs,conn
	set conn=server.CreateObject("adodb.connection")
	set rs=server.CreateObject("adodb.recordset")
	filepath=server.MapPath("access\backend\tickets.mdb")
	
	conn.open"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filepath
	rs.cursorlocation=3 'adUseClient
	rs.cursortype=0 'adOpenForwardOnly 
	rs.locktype=1 'adLockReadOnly 
	
	sql="select top 1 * from [" & request.Form("table") & "]"
	rs.open sql,conn
	rs.activeconnection=nothing
		
	for each f in rs.fields
		flds=flds & "<option value='" & f.name & "'>" & f.name & "</option>" & vbcrlf
		pflds=pflds & "<option value='" & f.name & "'>" & f.name & "'s</option>" & vbcrlf
	next
	rs.close
	conn.close
	set rs=nothing
	set conn=nothing
end if

%>
<form id="tableForm" name="tableForm" method="post" action="">
 customers.mdb tables
 <select name="table" id="table">
  <option value="tickets">tickets</option>
  <option value="Non_HomeSmart_Customers" selected="selected">Non_HomeSmart_Customers</option>
  <option value="Ticket_History">Ticket_History</option>
 <%= tbls %>
 </select>
 <input type="submit" name="Submit" value="Go" style="background-color:#00CCFF"/>
</form>
<form action="PivotChartData.asp" method="post" name="PivotForm" target="PivotChartData" id="PivotForm">
 <p>&nbsp;</p>
 <table width="100%" border="1" cellspacing="0" cellpadding="0">
  <tr>
   <td>
    <p>Show me the
     <select name="measure" size="5" id="measure" onchange="UpdateExample()">
      <option value="count">Count</option>
      <option value="sum">Sum</option>
      <option value="avg">Average</option>
      <option value="max">Maximum</option>
      <option value="min">Minimum</option>
      </select>
of all
<select name="MeasureObj" size="10" id="MeasureObj" onchange="UpdateExample()">
<%= pflds %>
</select>
for each
<select name="eachObj" size="10" id="eachObj" onchange="UpdateExample()">
<%= flds %>
</select>
, grouped by
<select name="groupedbyObj" size="10" id="groupedbyObj" onchange="UpdateExample()">
<%= flds %>
</select>
    </p>
    <p>(Optional) Filter:
     <input name="filterStr" type="text" id="filterStr" size="60" style="background-color:#FFFF99"/>
     <input name="tableObj" type="hidden" id="tableObj" value="<%= request.Form("table") %>"/>
    </p>
    <p>
     <input type="submit" name="Submit2" value="Submit" style="background-color:#00CCFF"/>
    </p>
   </td>
  </tr>
  <tr>
   <td>
    <table width="100%" border="1" cellspacing="0" cellpadding="0">
     <tr>
      <th scope="col">&nbsp;</th>
      <th scope="col" id="g1">grouped by 1 </th>
      <th scope="col" id="g2">grouped by 2 </th>
      <th scope="col" id="g3">grouped by 3 </th>
     </tr>
     <tr>
      <th scope="row" id="e1">each 1 </th>
      <td bgcolor="#FFFFFF" id="c1-1">calculation 1-1 </td>
      <td bgcolor="#FFFFFF" id="c1-2">calculation 1-2 </td>
      <td bgcolor="#FFFFFF" id="c1-3">calculation 1-3 </td>
     </tr>
     <tr>
      <th scope="row" id="e2">each 2 </th>
      <td bgcolor="#FFFFFF" id="c2-1">calculation 2-1 </td>
      <td bgcolor="#FFFFFF" id="c2-2">calculation 2-2 </td>
      <td bgcolor="#FFFFFF" id="c2-3">calculation 2-3 </td>
     </tr>
     <tr>
      <th scope="row" id="e3">each 3 </th>
      <td bgcolor="#FFFFFF" id="c3-1">calculation 3-1 </td>
      <td bgcolor="#FFFFFF" id="c3-2">calculation 3-2 </td>
      <td bgcolor="#FFFFFF" id="c3-3">calculation 3-3 </td>
     </tr>
    </table>
   </td>
  </tr>
  <tr>
   <td><iframe id="PivotChartData" name="PivotChartData" width="100%" height="500"></iframe></td>
  </tr>
 </table>
 <p>&nbsp;</p>
</form>
</body>


</html>
